/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interceptors;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import java.util.Map;

/**
 *
 * @author corneliugosa
 */
public class ApproveExam implements Interceptor{

    @Override
    public void destroy() {
        System.out.println("destroyed");
    }

    @Override
    public void init() {
        System.out.println("init");
    }

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        Map<String, Object> session = invocation.getInvocationContext().getSession();
        
        if(session.get("examStat")!=null && session.get("examStat").equals("approved")){
            System.out.println("Exam approved in the interceptor!");
            invocation.invoke();
        }
        
        return "failure";
    }
    
}
